<?php

Raise::load('core.RaiseObject');
Raise::load('core.collection.RaiseCollection');
Raise::load('core.net.http.RaiseHttpMethod');

/**
 * RaiseUrlRoute
 * A URL Routing Entry
 *
 * @author Sam-Mauris Yong / hellclanner at live dot com
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package phpraise.core
 * @since 1.2
 */
class RaiseUrlRoute extends RaiseObject {
    
    /**
     * The HTTP method that this URL route will cater for. Defaults to GET.
     * @var string
     */
    private $httpMethod = RaiseHttpMethod::GET;

    /**
     * The rewritten relative-to-host URL
     * @var string
     */
    private $rewrite;

    /**
     * The name of the RaisePage class to route to
     * @var string
     */
    private $actual;

    /**
     * The parameters in this routing
     * @var RaiseCollection
     */
    private $params;

    /**
     * Create a new RaiseUrlRoute entry
     * @param string|RaiseUrl $rw Rewrite version of the URL
     * @param string|RaiseUrl $ac Actual file
     * @param RaiseCollection|array $pa (optional) Parameters of the URL route
     */
    function __construct($rw, $ac, $mt = null, $pa = array()){
        $this->rewrite = $rw;
        $this->actual = $ac;
        if(!$mt){
            $mt = RaiseHttpMethod::GET;
        }
        $this->httpMethod = $mt;
        $this->params = new RaiseCollection($pa);
    }
    
    /**
     * Get the HTTP method for this URL route
     * @return string 
     */
    public function httpMethod(){
        return $this->httpMethod;
    }

    /**
     * Get the rewritten relative-to-host URL
     * @return string|RaiseUrl
     */
    public function rewrite(){
        return $this->rewrite;
    }

    /**
     * Get the name of the RaisePage class to route to
     * @return string
     */
    public function actual(){
        return $this->actual;
    }

    /**
     * Get the RaiseCollection of parameters for the route
     * @return RaiseCollection
     */
    public function params(){
        return $this->params;
    }

}


